﻿<?php
require 'Conn.php';
$username=mysql_real_escape_string($_POST['regpassname']);
$pwd=mysql_real_escape_string($_POST['regpassword1']);
$pwd1=mysql_real_escape_string($_POST['regpassword2']);
If ($username == "")
{
	echo "<Script>alert('请输入注册用户名！');history.go(-1);</Script>";
 	exit();
}
Else
	If ($pwd == "")
	{
		echo "<Script>alert('请输入注册密码！');history.go(-1);</Script>";
 		exit();
	}
	Else
		If ($pwd != $pwd1)
		{
			echo "<Script>alert('密码不一致！');history.go(-1);</Script>";
 			exit();
		}
		Else
		{ 
			$sql="SELECT * FROM userifo WHERE username='".$username."'";
			$result=mysql_query($sql,$Conn);		
			If (mysql_num_rows($result)>=1)
			{
				echo "<Script>alert('该账号已被注册！');history.go(-1);</Script>";	
 				exit();
			}
			Else
			{
				$sql="INSERT INTO 'userifo' ('username','pwd','point','lastlogin') VALUES('$username','$pwd',0,'".date('Y-m-d')."')";
				mysql_query($sql);
				session_start();
				$_SESSION['username']=$username;
    			header('Location:index.php');
			}
		}
?>